package Orm;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import vo.Program;


import java.io.IOException;
import java.io.InputStream;

public class DatabaseDriver
{
	private static final String resourcePath = "BatisConfig/mybatis-config.xml";
	public DatabaseDriver()
	{
		String resource = resourcePath;
		try
		{

			InputStream inputStream = Resources.getResourceAsStream(resource);
			SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
			SqlSession sqlSession = sqlSessionFactory.openSession();
			String statement = "programMapper.getDegree";

			Program program = sqlSession.selectOne(statement, "MA");
			System.out.println(program);

		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}
